var Hero = Unit.extend({
	speed  : 0,       // [readonly]
	goL    : 0,       // [property]
	goR    : 0,       // [property]
	goU    : 0,       // [property]
	goD    : 0,       // [property]
	hp     : 0,       // [property]
	color  : "black", // [readonly]
	
	_defaultX : 0,
	_defaultY : 0,
	
	render: function()
	{
		this._super();
		
		this._saveDefault();
		
		this.graphics.fillStyle(this.color);
		this.graphics.beginPath();
		this.graphics.rect(0, 0, this.width, this.height);
		this.graphics.closePath();
		this.graphics.fill();
		
		this.bind("mouseover", this._onMouseOver, this);
		this.bind("mouseout",  this._onMouseOut,  this);
		this.bind("mousemove", this._onMouseMove, this);
		this.bind("click",     this._onClick,     this);
	},
	
	restoreDefault: function()
	{
		this.setXY(this._defaultX, this._defaultY);
	},
	
	move: function()
	{
		this._saveDefault();
		
		this.setXY(
			this.x + this.speed * (this.goR - this.goL),
			this.y + this.speed * (this.goD - this.goU)
		);
	},
	
	_saveDefault: function()
	{
		this._defaultX = this.x;
		this._defaultY = this.y;
	},
	
	_onMouseOver: function()
	{
		console.log("over");
	},
	
	_onMouseOut: function()
	{
		console.log("out");
	},
	
	_onMouseMove: function(event)
	{
		console.log("move", event.local[0], event.local[1], event.global[0], event.global[1]);
		
		//var localByMap = map.globalToLocal(hero.localToGlobal(localByHero));
	},
	
	_onClick: function(event)
	{
		console.log("click", event.local[0], event.local[1], event.global[0], event.global[1]);
	}
});
